<?php 
add_action('wp_ajax_doapporder', 'my_ajax_update');
add_action('wp_ajax_nopriv_doapporder', 'my_ajax_update');
function my_ajax_update(){
if (isset($_POST['p'])){
		global $wpdb;
		global $tableordername;
		$inputData = array(
		'name' => strip_tags($_POST['field_fio']),
		'phone' => strip_tags($_POST['field_phone']),
		'email' => strip_tags($_POST['field_mail']),
		'fulladress' => $_POST['fulladress'],
		'indate' => strip_tags($_POST['field_datein']),
		'outdate' => strip_tags($_POST['field_dateout']),
		'avans' => $_POST['field_avans'],
		'paytype' => $_POST['field_payment'],
		'transfer' => $_POST['field_trans'],
		'meetdate' => strip_tags($_POST['field_date']),
		'meettime' => strip_tags($_POST['field_time']),
		'meetplace' => strip_tags($_POST['field_place']),
		'howmany' => strip_tags($_POST['field_count']),
		'recommendations' => strip_tags($_POST['field_note']),
		'totalprice' => $_POST['price'],
		'url' => $_POST['url'],
		'status' => strip_tags($_POST['status'])
		);
		// Добавляем новый заказ в базу	
		$wpdb->insert( $tableordername, $inputData );
		
		$admin_email = get_option('admin_email');
		$message = $inputData;
	
		$user_mail = strip_tags($_POST['field_mail']);
		wp_mail($admin_email, 'Поступил новый заказ', $message); 
		$headers = 'От: '.strip_tags($_POST['field_mail']).' '.strip_tags($_POST['field_mail'])."\r\n";
		wp_mail($user_mail, 'Yamme.ru | Ваш заказ',$message, $headers);
		
		echo "ready";
	}

}

?>